import 'package:distribution_mall_flutter/constant/cf_constant.dart';
import 'package:distribution_mall_flutter/constant/status_constant.dart';
import 'package:distribution_mall_flutter/entity/order/detail/order_detail_entity.dart';
import 'package:distribution_mall_flutter/generated/l10n.dart';
import 'package:distribution_mall_flutter/provider/order/order_detail.dart';
import 'package:distribution_mall_flutter/utils/utils.dart';
import 'package:distribution_mall_flutter/widgets/card.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

class PayCart extends ConsumerWidget {
  const PayCart({super.key});

  Widget listRender(
      {required String leftText,
      required String rightText,
      bool showDis = false}) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: EdgeConstant.edge5),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(
            leftText,
            style: const TextStyle(
                color: ColorConstant.grey153, fontSize: FontConstant.f14),
          ),
          Expanded(
              child: Padding(
            padding: const EdgeInsets.only(left: EdgeConstant.edge5),
            child: Text(
              rightText,
              overflow: TextOverflow.ellipsis,
              maxLines: 1,
              textAlign: TextAlign.end,
              style: const TextStyle(
                  color: ColorConstant.black51, fontSize: FontConstant.f14),
            ),
          ))
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    final orderModal = ref.watch(orderDetailProvider);
    return EPCard(
      margin: const EdgeInsets.fromLTRB(
          EdgeConstant.edge10, EdgeConstant.edge10, EdgeConstant.edge10, 0),
      padding: const EdgeInsets.all(
        EdgeConstant.edge10,
      ),
      child: Column(
        children: [
          listRender(
              leftText: S.of(context).payment_method,
              rightText: orderModal.paymentMethodName),
          listRender(
              leftText: S.of(context).order_state_of_payment,
              rightText: orderModal.detal?.payment?.paymentState != null
                  ? OrderPayStatusEnum.getStatusText(
                      orderModal.detal?.payment?.paymentState)
                  : '-'),
        ],
      ),
    );
  }
}
